package org.example.system.common.bean;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.example.system.common.constant.BaseConstant;

import java.time.LocalDateTime;

/**
 * mybatis实体基类-创建信息-更新信息
 * @author joey
 */
@Data
public class BaseEntity extends IdEntity {
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = BaseConstant.entity_date_format)
    @ApiModelProperty(value = "创建时间")
    @TableField(value = "createTime", fill = FieldFill.INSERT)
    protected LocalDateTime createTime;

    @JsonSerialize(using= ToStringSerializer.class)
    @ApiModelProperty(value = "创建人id")
    @TableField(value = "createBy", fill = FieldFill.INSERT)
    protected Long createBy;

    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = BaseConstant.entity_date_format)
    @ApiModelProperty(value = "更新时间")
    @TableField(value = "updateTime", fill = FieldFill.INSERT_UPDATE)
    protected LocalDateTime updateTime;

    @JsonSerialize(using= ToStringSerializer.class)
    @ApiModelProperty(value = "更新人id")
    @TableField(value = "updateBy", fill = FieldFill.INSERT_UPDATE)
    protected Long updateBy;

    @ApiModelProperty(value = "租户id")
    @TableField("tenantId")
    private Long tenantId;
}
